package com.hhxyjsj.framework.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Arrays;

import com.hhxyjsj.framework.logging.Logger;
import com.hhxyjsj.framework.logging.support.LoggerFacory;

public class LogProxy implements InvocationHandler {
	
	private Object obj;
	
	private Logger logger;
	
	public LogProxy(Object obj){
		this.obj = obj;
		this.logger = LoggerFacory.getLoggerAdapter(obj.getClass());
	}

	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		Object rvtObj = method.invoke(obj, args);
		logger.info(method.getName(),Arrays.toString(args),String.valueOf(rvtObj));
		return rvtObj;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}
}
